import JJAPPConfig from '../resource/file/appConfig/JJAPPConfig.js'
const { LogLevel } = JJAPPConfig;

const JJLog = { 
    debug(message) {
        if (LogLevel <= 0) {
            message = typeof message == 'object' ? JSON.stringify(message) : message
            console.debug(this.localTimeString() + "[d] " + message);
        }
    },
    info(message) {
        if (LogLevel <= 1) {
            message = typeof message == 'object' ? JSON.stringify(message) : message
            console.info(this.localTimeString() + "[i] " + message);
        }
    },
    warn(message) {
        if (LogLevel <= 2) {
            message = typeof message == 'object' ? JSON.stringify(message) : message
            console.warn(this.localTimeString() + "[w] " + message);
        }
    },
    error(message) {
        if (LogLevel <= 3) {
            message = typeof message == 'object' ? JSON.stringify(message) : message
            console.error(this.localTimeString() + "[e] " + message);
        }
    },
    localTimeString() {
        const time = new Date()
		const localString = time.toLocaleString() + ' '
		return localString
    },
}

export default JJLog;
